Set path Laura: ONLY USE FOR LAURA
# base_path <- "//home.kt.ktzh.ch/B117T23$/Desktop/Riskktaking/Data"
base_path <- "/Users/laurabazzigher/Documents/GitHub/risk_wvs/data/dataset/Data_S3"
Library
library(tidyverse)
library(ggplot2)
library(specr)
library(specr)
library(readxl)
library(ggthemes)
library(cowplot)
library(dplyr)
library(knitr)
library(kableExtra)
library(Hmisc)
remotes::install_github("masurp/specr")
Load all data
Load dataset to create Hardship-Index
risktaking <- read.csv(file.path(base_path, "Test_Specification_curve"), header=TRUE, as.is=TRUE)
hardship_Original <- read.csv(file.path(base_path, "countryfacts_cleaned.csv"), header=TRUE, as.is=TRUE)
#view(risktaking)
str(risktaking)
## 'data.frame': 229065 obs. of 9 variables:
## $ country : chr "Turkey" "Turkey" "Turkey" "Turkey" ...
## $ isocode : chr "TUR" "TUR" "TUR" "TUR" ...
## $ gender : int 1 1 1 0 0 0 1 0 0 0 ...
## $ age_scale : num -0.902 0.474 -1.189 -1.017 -1.017 ...
## $ age : int 26 50 21 24 24 19 25 40 32 34 ...
## $ hardship_index: num 0.0781 0.0781 0.0781 0.0781 0.0781 ...
## $ risktaking : num 60.2 53.9 60.2 62.7 61.2 ...
## $ source : chr "gps" "gps" "gps" "gps" ...
## $ worldmap : chr "both" "both" "both" "both" ...
str(hardship_Original)
## 'data.frame': 105 obs. of 11 variables:
## $ code : chr "AFG" "DZA" "AND" "ARG" ...
## $ label : chr "Afghanistan" "Algeria" "Andorra" "Argentina" ...
## $ codeWVS : int 4 12 20 32 51 36 40 31 50 112 ...
## $ homiciderate : num 0.7308 -0.9425 -0.3793 0.3012 0.0607 ...
## $ gdp : num 2.236 0.349 -1.084 -0.286 0.107 ...
## $ infantmortality : num 2.3758 0.6758 -1.3493 -0.0767 0.1896 ...
## $ lifeexpectancy : num 4.002 -0.437 -1.241 -0.48 -0.147 ...
## $ gini : num -0.996 -1.222 -1.272 0.627 -1.524 ...
## $ femalemale_primedu: num 8.8108 -0.2746 -0.2755 -0.2755 0.0156 ...
## $ hardship_index : num 2.86 -0.3086 -0.9336 -0.0316 -0.2164 ...
## $ country : chr "Afghanistan" "Algeria" "Andorra" "Argentina" ...
Hardship Countrylist
# Benenne 'code' in 'isocode' im zweiten Datensatz um
hardship_Original <- hardship_Original %>%
rename(isocode = code)
# Verwende 'left_join' um alle Daten aus 'risktaking' zu behalten und passende aus 'hardship_Original' hinzuzufügen
combined_data <- risktaking %>%
left_join(hardship_Original, by = "isocode")
# Überprüfe die ersten Zeilen des kombinierten Datensatzes
head(combined_data)
## country.x isocode gender age_scale age hardship_index.x risktaking source
## 1 Turkey TUR 1 -0.9021528 26 0.07814988 60.19755 gps
## 2 Turkey TUR 1 0.4737750 50 0.07814988 53.86746 gps
## 3 Turkey TUR 1 -1.1888045 21 0.07814988 60.19755 gps
## 4 Turkey TUR 0 -1.0168135 24 0.07814988 62.71073 gps
## 5 Turkey TUR 0 -1.0168135 24 0.07814988 61.22168 gps
## 6 Turkey TUR 0 -1.3034651 19 0.07814988 69.63037 gps
## worldmap label codeWVS homiciderate gdp infantmortality
## 1 both Turkey 792 0.2385052 -0.6480058 0.6560725
## 2 both Turkey 792 0.2385052 -0.6480058 0.6560725
## 3 both Turkey 792 0.2385052 -0.6480058 0.6560725
## 4 both Turkey 792 0.2385052 -0.6480058 0.6560725
## 5 both Turkey 792 0.2385052 -0.6480058 0.6560725
## 6 both Turkey 792 0.2385052 -0.6480058 0.6560725
## lifeexpectancy gini femalemale_primedu hardship_index.y country.y
## 1 -0.1578527 0.5769059 -0.1967259 0.07814988 Turkey
## 2 -0.1578527 0.5769059 -0.1967259 0.07814988 Turkey
## 3 -0.1578527 0.5769059 -0.1967259 0.07814988 Turkey
## 4 -0.1578527 0.5769059 -0.1967259 0.07814988 Turkey
## 5 -0.1578527 0.5769059 -0.1967259 0.07814988 Turkey
## 6 -0.1578527 0.5769059 -0.1967259 0.07814988 Turkey
# Überprüfe die Struktur des kombinierten Datensatzes, um sicherzustellen, dass keine Daten verloren gegangen sind
str(combined_data)
## 'data.frame': 229065 obs. of 19 variables:
## $ country.x : chr "Turkey" "Turkey" "Turkey" "Turkey" ...
## $ isocode : chr "TUR" "TUR" "TUR" "TUR" ...
## $ gender : int 1 1 1 0 0 0 1 0 0 0 ...
## $ age_scale : num -0.902 0.474 -1.189 -1.017 -1.017 ...
## $ age : int 26 50 21 24 24 19 25 40 32 34 ...
## $ hardship_index.x : num 0.0781 0.0781 0.0781 0.0781 0.0781 ...
## $ risktaking : num 60.2 53.9 60.2 62.7 61.2 ...
## $ source : chr "gps" "gps" "gps" "gps" ...
## $ worldmap : chr "both" "both" "both" "both" ...
## $ label : chr "Turkey" "Turkey" "Turkey" "Turkey" ...
## $ codeWVS : int 792 792 792 792 792 792 792 792 792 792 ...
## $ homiciderate : num 0.239 0.239 0.239 0.239 0.239 ...
## $ gdp : num -0.648 -0.648 -0.648 -0.648 -0.648 ...
## $ infantmortality : num 0.656 0.656 0.656 0.656 0.656 ...
## $ lifeexpectancy : num -0.158 -0.158 -0.158 -0.158 -0.158 ...
## $ gini : num 0.577 0.577 0.577 0.577 0.577 ...
## $ femalemale_primedu: num -0.197 -0.197 -0.197 -0.197 -0.197 ...
## $ hardship_index.y : num 0.0781 0.0781 0.0781 0.0781 0.0781 ...
## $ country.y : chr "Turkey" "Turkey" "Turkey" "Turkey" ...
hardship_combined <- combined_data %>% select(country.x , isocode, risktaking, age, gender, infantmortality, lifeexpectancy, gini, homiciderate, gdp, femalemale_primedu)
str(hardship_combined)
## 'data.frame': 229065 obs. of 11 variables:
## $ country.x : chr "Turkey" "Turkey" "Turkey" "Turkey" ...
## $ isocode : chr "TUR" "TUR" "TUR" "TUR" ...
## $ risktaking : num 60.2 53.9 60.2 62.7 61.2 ...
## $ age : int 26 50 21 24 24 19 25 40 32 34 ...
## $ gender : int 1 1 1 0 0 0 1 0 0 0 ...
## $ infantmortality : num 0.656 0.656 0.656 0.656 0.656 ...
## $ lifeexpectancy : num -0.158 -0.158 -0.158 -0.158 -0.158 ...
## $ gini : num 0.577 0.577 0.577 0.577 0.577 ...
## $ homiciderate : num 0.239 0.239 0.239 0.239 0.239 ...
## $ gdp : num -0.648 -0.648 -0.648 -0.648 -0.648 ...
## $ femalemale_primedu: num -0.197 -0.197 -0.197 -0.197 -0.197 ...
# Entferne alle Zeilen mit fehlenden Daten in den für die Analyse relevanten Spalten
hardship_combined <- hardship_combined %>%
filter(complete.cases(gender, infantmortality, lifeexpectancy, gini, homiciderate, gdp, femalemale_primedu))
# Stellen Sie sicher, dass die Alterskategorien richtig zugewiesen wurden
if (!"age_category" %in% names(hardship_combined)) {
hardship_combined$age_category <- cut(hardship_combined$age,
breaks = c(15, 24, 34, 44, 54, 64, 74, 84, 99),
labels = c("Youth (15-24)",
"Young Adults (25-34)",
"Middle-aged Adults (35-44)",
"Mature Adults (45-54)",
"Pre-seniors (55-64)",
"Early Seniors (65-74)",
"Seniors (75-84)",
"Elderly (85-99)"),
right = TRUE, include.lowest = TRUE)
}
# Umwandlung der Alterskategorien in numerische Werte
hardship_combined$age_numeric <- as.integer(factor(hardship_combined$age_category))
# Überprüfung der neuen numerischen Alterskategorien
table(hardship_combined$age_numeric)
##
## 1 2 3 4 5 6 7 8
## 40578 50751 44430 37290 28791 17688 7321 1117
Calculate correlation with risktaking
# Berechnung der Korrelation zwischen risktaking und den anderen Variablen
correlation_results <- cor(hardship_combined[, sapply(hardship_combined, is.numeric)], use = "complete.obs")
# Korrelationstabelle für risktaking extrahieren
risktaking_correlations <- correlation_results["risktaking", ]
# Konvertierung der Korrelationsergebnisse in ein formatiertes Datenframe
correlation_table <- data.frame(
Variable = names(risktaking_correlations),
Correlation = risktaking_correlations
)
# Entfernen der Korrelation von risktaking mit sich selbst
correlation_table <- correlation_table[correlation_table$Variable != "risktaking", ]
# Sortieren der Ergebnisse nach dem Betrag der Korrelation, absteigend
correlation_table <- correlation_table[order(-abs(correlation_table$Correlation)), ]
# Anzeigen der Tabelle
kable(correlation_table, caption = "Korrelationen zwischen risktaking und anderen Variablen") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
Korrelationen zwischen risktaking und anderen Variablen
|
|
Variable
|
Correlation
|
|
age
|
age
|
-0.2415320
|
|
age_numeric
|
age_numeric
|
-0.2391221
|
|
infantmortality
|
infantmortality
|
0.1454553
|
|
lifeexpectancy
|
lifeexpectancy
|
0.1387346
|
|
gender
|
gender
|
-0.1201338
|
|
gini
|
gini
|
0.1175359
|
|
gdp
|
gdp
|
0.1072607
|
|
homiciderate
|
homiciderate
|
0.1007516
|
|
femalemale_primedu
|
femalemale_primedu
|
0.0528604
|
Table with Correlation hardship factors and risktaking
# Laden notwendiger Bibliotheken
library(Hmisc)
library(kableExtra)
# Auswahl aller numerischen Variablen
numeric_vars <- hardship_combined %>%
select(where(is.numeric))
# Berechnen der Korrelationsmatrix und der p-Werte
cor_results <- rcorr(as.matrix(numeric_vars))
# Korrelationen und p-Werte spezifisch für 'risktaking' extrahieren
correlations <- cor_results$r[, "risktaking"] # Korrelationen zu 'risktaking'
p_values <- cor_results$P[, "risktaking"] # p-Werte zu 'risktaking'
# Datenrahmen für die Darstellung erstellen
cor_table <- data.frame(
Variable = rownames(cor_results$r), # Namen der Variablen
Correlation = round(correlations, 5), # Korrelationswerte, gerundet auf 5 Dezimalstellen
P_value = format(p_values, scientific = TRUE), # p-Werte in wissenschaftlicher Notation
Significant = ifelse(p_values < 0.05, "Yes", "No") # Signifikanzflag, basierend auf p-Wert
)
# Tabellendarstellung mit 'kable' und 'kableExtra'
cor_table %>%
kable("html", caption = "Correlations with Risktaking: Summary of Results") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
column_spec(2, bold = TRUE) %>%
column_spec(3, background = "lightyellow")
Correlations with Risktaking: Summary of Results
|
|
Variable
|
Correlation
|
P_value
|
Significant
|
|
risktaking
|
risktaking
|
1.00000
|
NA
|
NA
|
|
age
|
age
|
-0.24153
|
0e+00
|
Yes
|
|
gender
|
gender
|
-0.12013
|
0e+00
|
Yes
|
|
infantmortality
|
infantmortality
|
0.14546
|
0e+00
|
Yes
|
|
lifeexpectancy
|
lifeexpectancy
|
0.13873
|
0e+00
|
Yes
|
|
gini
|
gini
|
0.11754
|
0e+00
|
Yes
|
|
homiciderate
|
homiciderate
|
0.10075
|
0e+00
|
Yes
|
|
gdp
|
gdp
|
0.10726
|
0e+00
|
Yes
|
|
femalemale_primedu
|
femalemale_primedu
|
0.05286
|
0e+00
|
Yes
|
|
age_numeric
|
age_numeric
|
-0.23912
|
0e+00
|
Yes
|
colnames(hardship_combined)
## [1] "country.x" "isocode" "risktaking"
## [4] "age" "gender" "infantmortality"
## [7] "lifeexpectancy" "gini" "homiciderate"
## [10] "gdp" "femalemale_primedu" "age_category"
## [13] "age_numeric"
Setup for specifications
library(specr)
# Setup für die Spezifikationen mit einer umfassenderen Auswahl von Variablen
specification <- setup(
data = hardship_combined,
y = "risktaking", # abhängige Variable
x = c("infantmortality",
"lifeexpectancy", "gini", "homiciderate",
"gdp", "femalemale_primedu"),
model = "lm"
)
# Zusammenfassung der Spezifikationen
summary(specification)
## Setup for the Specification Curve Analysis
## -------------------------------------------
## Class: specr.setup -- version: 1.0.1
## Number of specifications: 6
##
## Specifications:
##
## Independent variable: infantmortality, lifeexpectancy, gini, homiciderate, gdp, femalemale_primedu
## Dependent variable: risktaking
## Models: lm
## Covariates: no covariates
## Subsets analyses: all
##
## Function used to extract parameters:
##
## function (x)
## broom::tidy(x, conf.int = TRUE)
## <environment: 0x1438f6668>
##
##
## Head of specifications table (first 6 rows):
## # A tibble: 6 × 6
## x y model controls subsets formula
## <chr> <chr> <chr> <chr> <chr> <glue>
## 1 infantmortality risktaking lm no covariates all risktaking ~ infant…
## 2 lifeexpectancy risktaking lm no covariates all risktaking ~ lifeex…
## 3 gini risktaking lm no covariates all risktaking ~ gini +…
## 4 homiciderate risktaking lm no covariates all risktaking ~ homici…
## 5 gdp risktaking lm no covariates all risktaking ~ gdp + 1
## 6 femalemale_primedu risktaking lm no covariates all risktaking ~ female…
run specifications
specification_results <- specr(specification)
specification_results
## Models fitted based on 6 specifications
## Number of cores used: 1
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.16 0.33 0.69 1.53 1.02 1.37
summary(specification_results, digits = 5)
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 1.416 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.15925 0.33481 0.69348 1.53306 1.01867 1.37243
##
## Descriptive summary of sample sizes:
##
## median min max
## 227966 227966 227966
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.53 0.0218 70.2
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.43 0.0214 66.9
## 3 gini risk… lm no cova… all riskta… 1.13 0.0200 56.5
## 4 homiciderate risk… lm no cova… all riskta… 0.982 0.0203 48.4
## 5 gdp risk… lm no cova… all riskta… 1.19 0.0231 51.5
## 6 femalemale_… risk… lm no cova… all riskta… 0.693 0.0274 25.3
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
summarizing the parameter distribution
summary(specification_results, type = "curve")
## # A tibble: 1 × 7
## median mad min max q25 q75 obs
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1.16 0.335 0.693 1.53 1.02 1.37 227966
summary(specification_results,
type = "curve",
group = "x",
stats = c("median", "mean", "min", "max")) # Statistiken in einem Vektor auflisten
## # A tibble: 6 × 6
## x median mean min max obs
## <chr> <dbl> <dbl> <dbl> <dbl> <int>
## 1 femalemale_primedu 0.693 0.693 0.693 0.693 227966
## 2 gdp 1.19 1.19 1.19 1.19 227966
## 3 gini 1.13 1.13 1.13 1.13 227966
## 4 homiciderate 0.982 0.982 0.982 0.982 227966
## 5 infantmortality 1.53 1.53 1.53 1.53 227966
## 6 lifeexpectancy 1.43 1.43 1.43 1.43 227966
Plots
plot(specification_results)

(a <- plot(specification_results, type = "curve", ci = F, ribbon = T) +
geom_point(size = 4))

(b <- plot(specification_results, type = "choices", choices = c("x", "y", "model", "controls")) +
geom_point(size = 2, shape = 4))

(c <- plot(specification_results, type = "samplesizes") + ylim(0, 400))

plot_grid(a, b, c, ncol = 1,
align = "v",
rel_heights = c(1.5, 2, 0.8),
axis = "rbl")

plot(specification_results, type = "boxplot") +
geom_point(alpha = .4) +
scale_fill_brewer(palette = "Pastel2") +
labs(x = "Effect size", fill = "")

# Überprüfe alle Spalten auf NA-Werte nach dem Filtern
sapply(hardship_combined, function(x) sum(is.na(x)))
## country.x isocode risktaking age
## 0 0 0 0
## gender infantmortality lifeexpectancy gini
## 0 0 0 0
## homiciderate gdp femalemale_primedu age_category
## 0 0 0 0
## age_numeric
## 0
# Überprüfe, ob alle Zeilen komplett sind
sum(!complete.cases(hardship_combined))
## [1] 0
# Überprüfe, ob die Daten, die an specr übergeben werden, komplett sind
if(anyNA(hardship_combined)) {
stop("Es gibt noch NA-Werte in den Daten.")
}
# Falls kein Fehler auftritt, führe specr aus
specification_results <- specr(specification)
summary(specification_results, digits = 5)
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.919 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.15925 0.33481 0.69348 1.53306 1.01867 1.37243
##
## Descriptive summary of sample sizes:
##
## median min max
## 227966 227966 227966
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.53 0.0218 70.2
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.43 0.0214 66.9
## 3 gini risk… lm no cova… all riskta… 1.13 0.0200 56.5
## 4 homiciderate risk… lm no cova… all riskta… 0.982 0.0203 48.4
## 5 gdp risk… lm no cova… all riskta… 1.19 0.0231 51.5
## 6 femalemale_… risk… lm no cova… all riskta… 0.693 0.0274 25.3
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
# Überprüfe die Daten in den Summary-Aufrufen
if(anyNA(specification_results$estimate)) {
stop("Es gibt NA-Werte in den Schätzungen.")
}
summary(specification_results, type = "curve")
## # A tibble: 1 × 7
## median mad min max q25 q75 obs
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1.16 0.335 0.693 1.53 1.02 1.37 227966
Subsetting data for males
specification_males <- setup(
data = hardship_combined %>%
filter(gender == 1), # Filter for males
y = "risktaking",
x = c("infantmortality",
"lifeexpectancy", "gini", "homiciderate",
"gdp", "femalemale_primedu"),
model = "lm"
)
# Run the specifications for males
specification_results_males <- specr(specification_males)
# Anpassen der Summary-Funktion, um mit NA-Werten umzugehen
safe_summary <- function(spec_results) {
tryCatch({
med <- median(spec_results$estimate, na.rm = TRUE)
q25 <- quantile(spec_results$estimate, 0.25, na.rm = TRUE)
q75 <- quantile(spec_results$estimate, 0.75, na.rm = TRUE)
data.frame(median = med, Q25 = q25, Q75 = q75)
}, error = function(e) {
message("Fehler beim Berechnen der Zusammenfassung: ", e$message)
})
}
# Run the specifications for males
specification_results_males <- specr(specification_males)
# View the summary of the results
summary(specification_results_males)
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.56 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.27 0.38 0.82 1.68 1.1 1.51
##
## Descriptive summary of sample sizes:
##
## median min max
## 120808 120808 120808
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.68 0.03 56.0
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.57 0.03 53.0
## 3 gini risk… lm no cova… all riskta… 1.2 0.03 44.3
## 4 homiciderate risk… lm no cova… all riskta… 1.06 0.03 38.7
## 5 gdp risk… lm no cova… all riskta… 1.35 0.03 42.4
## 6 femalemale_… risk… lm no cova… all riskta… 0.82 0.04 21.3
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
Plots for male subset results
plot(specification_results_males)

(a_male <- plot(specification_results_males, type = "curve", ci = F, ribbon = T) +
geom_point(size = 4))

(b_male <- plot(specification_results_males, type = "choices", choices = c("x", "y", "model", "controls")) +
geom_point(size = 2, shape = 4))

(c_male <- plot(specification_results_males, type = "samplesizes") + ylim(0, 400))

plot_grid(a_male, b_male, c_male, ncol = 1,
align = "v",
rel_heights = c(1.5, 2, 0.8),
axis = "rbl")

plot(specification_results_males, type = "boxplot") +
geom_point(alpha = .4) +
scale_fill_brewer(palette = "Pastel2") +
labs(x = "Effect size", fill = "")

Subsetting data for females
specification_females <- setup(
data = hardship_combined %>%
filter(gender == 0), # Filter for females
y = "risktaking",
x = c("infantmortality",
"lifeexpectancy", "gini", "homiciderate",
"gdp", "femalemale_primedu"),
model = "lm"
)
# Run the specifications for females
specification_results_females <- specr(specification_females)
# Anpassen der Summary-Funktion, um mit NA-Werten umzugehen
safe_summary <- function(spec_results) {
tryCatch({
med <- median(spec_results$estimate, na.rm = TRUE)
q25 <- quantile(spec_results$estimate, 0.25, na.rm = TRUE)
q75 <- quantile(spec_results$estimate, 0.75, na.rm = TRUE)
data.frame(median = med, Q25 = q25, Q75 = q75)
}, error = function(e) {
message("Fehler beim Berechnen der Zusammenfassung: ", e$message)
})
}
# Run the specifications for females
specification_results_females <- specr(specification_females)
# View the summary of the results
summary(specification_results_females)
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.376 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 0.98 0.25 0.52 1.31 0.9 1.17
##
## Descriptive summary of sample sizes:
##
## median min max
## 107158 107158 107158
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.31 0.03 41.5
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.23 0.03 40.1
## 3 gini risk… lm no cova… all riskta… 1 0.03 34.4
## 4 homiciderate risk… lm no cova… all riskta… 0.89 0.03 29.8
## 5 gdp risk… lm no cova… all riskta… 0.96 0.03 29.0
## 6 femalemale_… risk… lm no cova… all riskta… 0.52 0.04 13.5
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
Plots for female subset results
plot(specification_results_females)

(a_female <- plot(specification_results_females, type = "curve", ci = F, ribbon = T) +
geom_point(size = 4))

(b_female <- plot(specification_results_females, type = "choices", choices = c("x", "y", "model", "controls")) +
geom_point(size = 2, shape = 4))

(c_female <- plot(specification_results_females, type = "samplesizes") + ylim(0, 400))

plot_grid(a_female, b_female, c_female, ncol = 1,
align = "v",
rel_heights = c(1.5, 2, 0.8),
axis = "rbl")

plot(specification_results_females, type = "boxplot") +
geom_point(alpha = .4) +
scale_fill_brewer(palette = "Pastel2") +
labs(x = "Effect size", fill = "")

Subsetting data for age-categories
run_specification_for_age <- function(data, age_id, age_label) {
# Daten für die spezifische Altersgruppe filtern
data_subset <- data %>%
filter(age_numeric == age_id)
# Setup für die Spezifikationen durchführen
specification <- setup(
data = data_subset,
y = "risktaking",
x = c("infantmortality",
"lifeexpectancy", "gini", "homiciderate",
"gdp", "femalemale_primedu"),
model = "lm"
)
# Spezifikationsergebnisse berechnen
specification_results <- specr(specification)
# Statistische Auswertungen drucken mit Alterskategorie-Titel
cat("\nStatistische Ergebnisse für die Alterskategorie:", age_label, "\n")
print(summary(specification_results, digits = 5))
# Grafiken für die spezifische Altersgruppe erzeugen und anzeigen
plot_list <- list(
plot_a = plot(specification_results, type = "curve", ci = FALSE, ribbon = TRUE) +
geom_point(size = 4) + ggtitle(paste("Curve Plot -", age_label)),
plot_b = plot(specification_results, type = "choices", choices = c("x", "y", "model", "controls")) +
geom_point(size = 2, shape = 4) + ggtitle(paste("Choices Plot -", age_label)),
plot_c = plot(specification_results, type = "samplesizes") + ylim(0, 400) +
ggtitle(paste("Sample Sizes Plot -", age_label)),
plot_d = plot(specification_results, type = "boxplot") +
geom_point(alpha = .4) + scale_fill_brewer(palette = "Pastel2") +
labs(x = "Effect size", fill = "") + ggtitle(paste("Boxplot -", age_label))
)
# Rückgabe der Ergebnisse und Plots
return(list(summary = summary(specification_results, digits = 5), plots = plot_list))
}
# Funktion für jede Altersgruppe aufrufen und sowohl statistische Zusammenfassungen als auch Plots ausgeben
for (i in 1:8) {
results <- run_specification_for_age(hardship_combined, i, paste("Age Group", i))
print(results$summary) # Drucke die Zusammenfassung der Ergebnisse
print(results$plots$plot_a)
print(results$plots$plot_b)
print(results$plots$plot_c)
print(results$plots$plot_d)
}
##
## Statistische Ergebnisse für die Alterskategorie: Age Group 1
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.128 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## -0.06413 0.06737 -0.34792 0.34902 -0.07123 -0.00161
##
## Descriptive summary of sample sizes:
##
## median min max
## 40578 40578 40578
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… -0.0612 0.0530 -1.16
## 2 lifeexpecta… risk… lm no cova… all riskta… 0.0183 0.0479 0.381
## 3 gini risk… lm no cova… all riskta… 0.349 0.0439 7.95
## 4 homiciderate risk… lm no cova… all riskta… -0.0726 0.0497 -1.46
## 5 gdp risk… lm no cova… all riskta… -0.348 0.0516 -6.75
## 6 femalemale_… risk… lm no cova… all riskta… -0.0670 0.0473 -1.42
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.128 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## -0.06413 0.06737 -0.34792 0.34902 -0.07123 -0.00161
##
## Descriptive summary of sample sizes:
##
## median min max
## 40578 40578 40578
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… -0.0612 0.0530 -1.16
## 2 lifeexpecta… risk… lm no cova… all riskta… 0.0183 0.0479 0.381
## 3 gini risk… lm no cova… all riskta… 0.349 0.0439 7.95
## 4 homiciderate risk… lm no cova… all riskta… -0.0726 0.0497 -1.46
## 5 gdp risk… lm no cova… all riskta… -0.348 0.0516 -6.75
## 6 femalemale_… risk… lm no cova… all riskta… -0.0670 0.0473 -1.42
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL




##
## Statistische Ergebnisse für die Alterskategorie: Age Group 2
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.186 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 0.71707 0.24247 0.55288 0.93451 0.57115 0.8692
##
## Descriptive summary of sample sizes:
##
## median min max
## 50751 50751 50751
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 0.888 0.0470 18.9
## 2 lifeexpecta… risk… lm no cova… all riskta… 0.935 0.0433 21.6
## 3 gini risk… lm no cova… all riskta… 0.812 0.0406 20.0
## 4 homiciderate risk… lm no cova… all riskta… 0.622 0.0449 13.9
## 5 gdp risk… lm no cova… all riskta… 0.553 0.0464 11.9
## 6 femalemale_… risk… lm no cova… all riskta… 0.554 0.0487 11.4
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.186 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 0.71707 0.24247 0.55288 0.93451 0.57115 0.8692
##
## Descriptive summary of sample sizes:
##
## median min max
## 50751 50751 50751
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 0.888 0.0470 18.9
## 2 lifeexpecta… risk… lm no cova… all riskta… 0.935 0.0433 21.6
## 3 gini risk… lm no cova… all riskta… 0.812 0.0406 20.0
## 4 homiciderate risk… lm no cova… all riskta… 0.622 0.0449 13.9
## 5 gdp risk… lm no cova… all riskta… 0.553 0.0464 11.9
## 6 femalemale_… risk… lm no cova… all riskta… 0.554 0.0487 11.4
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL




##
## Statistische Ergebnisse für die Alterskategorie: Age Group 3
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.174 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 0.89023 0.23154 0.46728 1.17874 0.81302 1.07147
##
## Descriptive summary of sample sizes:
##
## median min max
## 44430 44430 44430
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.12 0.0496 22.5
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.18 0.0486 24.3
## 3 gini risk… lm no cova… all riskta… 0.939 0.0443 21.2
## 4 homiciderate risk… lm no cova… all riskta… 0.842 0.0454 18.5
## 5 gdp risk… lm no cova… all riskta… 0.803 0.0525 15.3
## 6 femalemale_… risk… lm no cova… all riskta… 0.467 0.0642 7.28
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.174 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 0.89023 0.23154 0.46728 1.17874 0.81302 1.07147
##
## Descriptive summary of sample sizes:
##
## median min max
## 44430 44430 44430
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.12 0.0496 22.5
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.18 0.0486 24.3
## 3 gini risk… lm no cova… all riskta… 0.939 0.0443 21.2
## 4 homiciderate risk… lm no cova… all riskta… 0.842 0.0454 18.5
## 5 gdp risk… lm no cova… all riskta… 0.803 0.0525 15.3
## 6 femalemale_… risk… lm no cova… all riskta… 0.467 0.0642 7.28
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL




##
## Statistische Ergebnisse für die Alterskategorie: Age Group 4
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.145 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 0.80354 0.29588 0.36337 1.08508 0.68843 1.0086
##
## Descriptive summary of sample sizes:
##
## median min max
## 37290 37290 37290
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.09 0.0547 19.9
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.06 0.0562 18.9
## 3 gini risk… lm no cova… all riskta… 0.845 0.0501 16.9
## 4 homiciderate risk… lm no cova… all riskta… 0.664 0.0487 13.6
## 5 gdp risk… lm no cova… all riskta… 0.762 0.0605 12.6
## 6 femalemale_… risk… lm no cova… all riskta… 0.363 0.0850 4.28
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.145 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 0.80354 0.29588 0.36337 1.08508 0.68843 1.0086
##
## Descriptive summary of sample sizes:
##
## median min max
## 37290 37290 37290
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.09 0.0547 19.9
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.06 0.0562 18.9
## 3 gini risk… lm no cova… all riskta… 0.845 0.0501 16.9
## 4 homiciderate risk… lm no cova… all riskta… 0.664 0.0487 13.6
## 5 gdp risk… lm no cova… all riskta… 0.762 0.0605 12.6
## 6 femalemale_… risk… lm no cova… all riskta… 0.363 0.0850 4.28
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL




##
## Statistische Ergebnisse für die Alterskategorie: Age Group 5
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.167 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.03551 0.28269 0.84042 1.31917 0.89469 1.22332
##
## Descriptive summary of sample sizes:
##
## median min max
## 28791 28791 28791
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.32 0.0626 21.1
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.28 0.0660 19.4
## 3 gini risk… lm no cova… all riskta… 1.03 0.0586 17.6
## 4 homiciderate risk… lm no cova… all riskta… 0.849 0.0534 15.9
## 5 gdp risk… lm no cova… all riskta… 1.04 0.0712 14.6
## 6 femalemale_… risk… lm no cova… all riskta… 0.840 0.117 7.20
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.167 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.03551 0.28269 0.84042 1.31917 0.89469 1.22332
##
## Descriptive summary of sample sizes:
##
## median min max
## 28791 28791 28791
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.32 0.0626 21.1
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.28 0.0660 19.4
## 3 gini risk… lm no cova… all riskta… 1.03 0.0586 17.6
## 4 homiciderate risk… lm no cova… all riskta… 0.849 0.0534 15.9
## 5 gdp risk… lm no cova… all riskta… 1.04 0.0712 14.6
## 6 femalemale_… risk… lm no cova… all riskta… 0.840 0.117 7.20
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL




##
## Statistische Ergebnisse für die Alterskategorie: Age Group 6
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.082 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.10142 0.26515 0.43358 1.31442 0.78785 1.22477
##
## Descriptive summary of sample sizes:
##
## median min max
## 17688 17688 17688
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.31 0.0813 16.2
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.16 0.0867 13.4
## 3 gini risk… lm no cova… all riskta… 1.25 0.0759 16.4
## 4 homiciderate risk… lm no cova… all riskta… 0.703 0.0666 10.6
## 5 gdp risk… lm no cova… all riskta… 1.04 0.0938 11.1
## 6 femalemale_… risk… lm no cova… all riskta… 0.434 0.181 2.40
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.082 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.10142 0.26515 0.43358 1.31442 0.78785 1.22477
##
## Descriptive summary of sample sizes:
##
## median min max
## 17688 17688 17688
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.31 0.0813 16.2
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.16 0.0867 13.4
## 3 gini risk… lm no cova… all riskta… 1.25 0.0759 16.4
## 4 homiciderate risk… lm no cova… all riskta… 0.703 0.0666 10.6
## 5 gdp risk… lm no cova… all riskta… 1.04 0.0938 11.1
## 6 femalemale_… risk… lm no cova… all riskta… 0.434 0.181 2.40
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL




##
## Statistische Ergebnisse für die Alterskategorie: Age Group 7
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.046 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.22713 0.1289 0.6883 1.62917 1.16115 1.30419
##
## Descriptive summary of sample sizes:
##
## median min max
## 7321 7321 7321
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.63 0.131 12.5
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.20 0.141 8.55
## 3 gini risk… lm no cova… all riskta… 1.25 0.120 10.4
## 4 homiciderate risk… lm no cova… all riskta… 0.688 0.104 6.63
## 5 gdp risk… lm no cova… all riskta… 1.32 0.153 8.65
## 6 femalemale_… risk… lm no cova… all riskta… 1.15 0.306 3.75
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.046 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.22713 0.1289 0.6883 1.62917 1.16115 1.30419
##
## Descriptive summary of sample sizes:
##
## median min max
## 7321 7321 7321
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.63 0.131 12.5
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.20 0.141 8.55
## 3 gini risk… lm no cova… all riskta… 1.25 0.120 10.4
## 4 homiciderate risk… lm no cova… all riskta… 0.688 0.104 6.63
## 5 gdp risk… lm no cova… all riskta… 1.32 0.153 8.65
## 6 femalemale_… risk… lm no cova… all riskta… 1.15 0.306 3.75
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL




##
## Statistische Ergebnisse für die Alterskategorie: Age Group 8
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.023 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.46075 0.40536 0.32897 1.74427 0.8879 1.71158
##
## Descriptive summary of sample sizes:
##
## median min max
## 1117 1117 1117
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.74 0.335 5.20
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.25 0.338 3.69
## 3 gini risk… lm no cova… all riskta… 0.768 0.314 2.45
## 4 homiciderate risk… lm no cova… all riskta… 0.329 0.271 1.21
## 5 gdp risk… lm no cova… all riskta… 1.72 0.375 4.60
## 6 femalemale_… risk… lm no cova… all riskta… 1.67 0.458 3.65
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL
## Results of the specification curve analysis
## -------------------
## Technical details:
##
## Class: specr.object -- version: 1.0.1
## Cores used: 1
## Duration of fitting process: 0.023 sec elapsed
## Number of specifications: 6
##
## Descriptive summary of the specification curve:
##
## median mad min max q25 q75
## 1.46075 0.40536 0.32897 1.74427 0.8879 1.71158
##
## Descriptive summary of sample sizes:
##
## median min max
## 1117 1117 1117
##
## Head of the specification results (first 6 rows):
##
## # A tibble: 6 × 24
## x y model controls subsets formula estimate std.error statistic
## <chr> <chr> <chr> <chr> <chr> <glue> <dbl> <dbl> <dbl>
## 1 infantmorta… risk… lm no cova… all riskta… 1.74 0.335 5.20
## 2 lifeexpecta… risk… lm no cova… all riskta… 1.25 0.338 3.69
## 3 gini risk… lm no cova… all riskta… 0.768 0.314 2.45
## 4 homiciderate risk… lm no cova… all riskta… 0.329 0.271 1.21
## 5 gdp risk… lm no cova… all riskta… 1.72 0.375 4.60
## 6 femalemale_… risk… lm no cova… all riskta… 1.67 0.458 3.65
## # ℹ 15 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
## # fit_r.squared <dbl>, fit_adj.r.squared <dbl>, fit_sigma <dbl>,
## # fit_statistic <dbl>, fit_p.value <dbl>, fit_df <dbl>, fit_logLik <dbl>,
## # fit_AIC <dbl>, fit_BIC <dbl>, fit_deviance <dbl>, fit_df.residual <dbl>,
## # fit_nobs <dbl>
## NULL



